package net.seninp.fdata.data;

import java.util.Iterator;

public class Year implements Iterable<Month> {

  private Integer year;
  private Months months;

  public Year(Integer year) {
    this.year = year;
    this.months = new Months();
  }

  public void add(Measurement m) {
    this.months.add(m);
  }

  /**
   * Whether consolidated year complete or not.
   *
   * @return
   */
  public boolean isComplete() {
    if (12 == this.months.size()) {
      return true;
    }
    return false;
  }

  /**
   * Whether particular fishery year complete or not.
   *
   * @return
   */
  public boolean isComplete(String fishery) {
    if (12 == this.months.size()) {
      for (int m = 1; m < 13; m++) {
        if (!this.months.get(m).hasMeasurements(fishery)) {
          return false;
        }
      }
      return true;
    }
    return false;
  }

  public int getMeasurementsCount() {
    return months.measurementsCount();
  }

  @Override
  public Iterator<Month> iterator() {
    return months.iterator();
  }

  public Integer getYear() {
    return this.year;
  }

  public Month getMonth(int m) {
    return this.months.get(m);
  }

}
